package com.lbd99.data.lbd.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lbd99.data.lbd.service.TComplaintService;
import com.lbd99.data.lbd.vo.TComplaint;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @auther: zhaojun
 * @date 2018-10-24 13:38
 * @description:
 * @version: 1.0
 * @company NengLiangKongJian
 */
@Controller
@RequestMapping("TComplaint")
public class TComplaintController {

    @Autowired
    private TComplaintService tComplaintService;

    /**
     * 分页查询数据
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping(value = "/getTComplaintList")
    @ResponseBody
    public Map<String, Object> getTComplaintList(int page,int rows,String phone,String uid){
        Map<String, Object> result = new HashMap<String, Object>();
        //拼装map条件
        Map<String,Object> datamap=new HashMap<String,Object>();
        if(StringUtils.isNotBlank(phone)){
            datamap.put("phone", StringUtils.trim(phone));
        }
        if(StringUtils.isNotBlank(uid)){
            datamap.put("uid", StringUtils.trim(uid));
        }
        /**===============================================*/
        PageHelper.startPage(page, rows);
        List<Map<String,Object>> list = tComplaintService.getTComplaintList(datamap);
        PageInfo<Map<String,Object>> pages = new PageInfo<>(list);
        result.put("total", pages.getTotal());
        result.put("rows", pages.getList());
        return result;
    }


}
